home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir37 / splt-bat.zip / TEST.BAT < prev   
DOS Batch File  |  1993-03-23  |  5KB  |  190 lines

  1. @ECHO OFF
  2. REM If no file specified go to end 
  3. IF "%1"=="" GOTO End
  4.  
  5. REM Converts input to upper case. Not necessary but I used it to get the output
  6. REM at the end in uppercase. This particular routine, except the line reading
  7. REM SET Pathname= should be removed. %UpCase% should then be be changed to
  8. REM %1. It should also be changed everywhere else in the file. These places
  9. REM will be indicated by asterisks.
  10. SET OldPath=%Path%
  11. PATH=%1
  12. SET UpCase=%Path%
  13. SET Path=%OldPath%
  14. SET PathName=%UpCase%
  15. SET OldPath=
  16.  
  17. REM this routine determines if a path was attached to the file specified.
  18. REM If no path was indicated the batch then branches to SetExt.
  19. :PathSeek
  20. SET Prev=%PathName%
  21. FOR %%a IN (/%pathName%) DO SET PathName=%%a
  22. IF "\%PathName%"=="%Prev%" GOTO PathFound
  23. SET Count=%Count%x
  24. IF NOT "%PathName%"=="%Prev%" GOTO PathSeek
  25. REM *****************
  26. SET FileName=%UpCase%
  27. SET PathName=
  28. GOTO SetExt
  29.  
  30.  
  31. :PathFound
  32. REM **************** Little square box entered with Alt-254 on numeric keypad
  33. SET PathName=%UpCase%■
  34. SET Count=
  35. SET BackCount=
  36.  
  37. REM this routine determines the path's length.
  38. :PathLength
  39. SET Prev=%PathName%
  40. FOR %%a IN (/%PathName%) DO SET PathName=%%a 
  41. FOR %%a IN (/%Prev%) DO IF "%%a"=="\" GOTO BackSlash
  42. FOR %%a IN (/%Prev%) DO IF "%%a"=="■" GOTO FileSetup
  43. SET Count=%Count%x
  44. REM ECHO Value of PathName is %PathName%
  45. REM ECHO Value of Count %Count%
  46. GOTO PathLength
  47. :BackSlash
  48. REM ECHO VALUE OF PATHNAME IS %PathName%
  49. SET BackCount=%BackCount%x
  50. GOTO PathLength
  51.  
  52. :FileSetup
  53. REM *****************
  54. SET FileName=%UpCase%
  55. SET BkCount=
  56.  
  57. REM This routine gets the filename with its extension.
  58. :FileGet
  59. SET Prev=%FileName%
  60. FOR %%a IN (/%FileName%) DO SET FileName=%%a
  61. FOR %%a IN (/%Prev%) DO IF "%%a"=="\" GOTO Back
  62. REM ECHO Value of FileName is %FileName%
  63. GOTO FileGet
  64. :Back
  65. REM ECHO VALUE OF FileName IS %FileName%
  66. SET BkCount=%BkCount%x
  67. IF NOT "%BkCount%"=="%BackCount%" GOTO FileGet
  68.  
  69. SET TempFile=%FileName%■
  70. SET Count=
  71.  
  72. REM this routine gets the file and its extension's length.
  73. :FileLength
  74. SET Prev=%TempFile%
  75. FOR %%a IN (/%TempFile%) DO SET TempFile=%%a 
  76. FOR %%a IN (/%Prev%) DO IF "%%a"=="■" GOTO PathSetup
  77. SET Count=%Count%x
  78. REM ECHO Value of TempFile is %TempFile%
  79. REM ECHO Value of Count is %Count%
  80. GOTO FileLength
  81.  
  82.  
  83. :PathSetup
  84. SET Count=%Count%x
  85. REM *****************
  86. SET PathName=%UpCase%
  87. SET BkCount=
  88. SET File=
  89. SET TempFile=
  90.  
  91.  
  92. REM the following routines will get the files pathname.
  93. :PathGet1
  94. SET Prev=%PathName%
  95. FOR %%a IN (/%PathName%) DO SET PathName=%%a
  96. FOR %%a IN (/%Prev%) DO IF "%%a%PathName%"=="%Prev%" SET PathName=%PathName%%%a
  97. FOR %%a IN (/%Prev%) DO IF "%%a"=="\" GOTO BackAgain
  98. REM ECHO Value of PathName is %PathName%
  99. GOTO PathGet1
  100. :BackAgain
  101. REM ECHO VALUE OF PATHNAME IS %PathName%
  102. SET BkCount=%BkCount%x
  103. IF NOT "%BkCount%"=="%BackCount%" GOTO PathGet1
  104.  
  105. SET Counter=
  106.  
  107. :PathGet2
  108. FOR %%a IN (/%PathName%) DO SET PathName=%%a
  109. SET Counter=%Counter%x
  110. REM ECHO VALUE OF PATHNAME IS %PathName%
  111. IF NOT "%Counter%"=="%Count%" GOTO PathGet2
  112.  
  113. SET Counter=
  114. SET Count=
  115. SET BkCount=
  116. SET BackCount=
  117.  
  118. :SetExt
  119.  
  120. SET Ext=%FileName%
  121.  
  122. REM this routine checks to see if the specified file had an extension.
  123. REM This comes from Prof. Timo Salmi's collection of batch files TSBAT*.ZIP
  124. REM a good primer for batch programming.
  125. :ExtCheck
  126. SET Prev=%Ext%
  127. FOR %%a IN (/%Ext%) DO SET Ext=%%a
  128. IF ".%Ext%"=="%Prev%" GOTO ExtFound
  129. REM ECHO Value of Ext is %Ext%
  130. SET Count=%Count%x
  131. IF NOT "%Ext%"=="%Prev%" GOTO ExtCheck
  132. SET Name=%FileName%
  133. SET Ext=
  134. GOTO NoExt
  135.  
  136. :ExtFound
  137. SET Prev=
  138. SET Len=
  139. SET NewExt=%Ext%■
  140.  
  141. REM this routine determines the length of the extension.
  142. :FindLen
  143. FOR %%a IN (/%NewExt%) DO SET NewExt=%%a
  144. SET Len=%Len%x
  145. IF NOT "%NewExt%"=="■" GOTO FindLen
  146.  
  147. SET NewExt=
  148. SET Name=%FileName%
  149. SET NewCount=
  150.  
  151. REM the following routines chop off the extension to get the files's name.
  152. :ChopExt 
  153. SET Prev=%Name%
  154. FOR %%a IN (/%Name%) DO SET Name=%%a
  155. FOR %%a IN (/%Prev%) DO IF "%%a%Name%"=="%Prev%" SET Name=%Name%%%a
  156. REM ECHO Value of Name is %Name%
  157. SET NewCount=%NewCount%x
  158. IF NOT "%Count%"=="%NewCount%" GOTO ChopExt
  159.  
  160. SET NewCount=
  161. SET NewLen=
  162.  
  163. :GetName
  164. SET Prev=%Name%
  165. FOR %%a IN (/%Name%) DO SET Name=%%a
  166. REM ECHO Value of Name is %Name%
  167. SET NewLen=%NewLen%x
  168. IF NOT "%NewLen%"=="%Len%x" GOTO GetName
  169. SET NewLen=
  170. SET Len=
  171.  
  172. :NoExt
  173. SET FileName=
  174. SET Count=
  175. SET Prev=
  176.  
  177. IF NOT "%PathName%"=="" SET PathState=full Path Name is "%PathName%",
  178. IF NOT "%Name%"=="" SET NameState=Name is "%Name%"
  179. IF NOT "%Ext%"=="" SET ExtState=, and Extension is "%Ext%"
  180.  
  181.  
  182. cls
  183. ECHO B"%UpCase%"'s %PathState% %NameState%%ExtState% 
  184. SET PathState=
  185. SET NameState=
  186. SET ExtState=
  187.  
  188. :End
  189.  
  190.